# frozen_string_literal: true
PROJECT = 'estate'
RAILS_ROOT = "/root/#{PROJECT}/current"
RAILS_ENV = 'production'
PORT = 7046

God.watch do |w|
  w.group = PROJECT
  w.name = "#{PROJECT}_thin"
  w.pid_file = File.join(RAILS_ROOT, 'tmp/pids/thin.pid')

  w.start = "cd #{RAILS_ROOT} && bundle exec thin -p #{PORT} start -R config.ru -e #{RAILS_ENV} --threaded -d"
  w.stop  = "cd #{RAILS_ROOT} && bundle exec thin stop"
  w.restart = "cd #{RAILS_ROOT} && #{w.stop} && #{w.start}"

  w.keepalive
end

God.watch do |w|
  w.group = PROJECT
  w.name = 'sidekiq'
  w.pid_file = File.join(RAILS_ROOT, 'tmp/pids/sidekiq.pid')

  w.start = "cd #{RAILS_ROOT} && RAILS_ENV=#{RAILS_ENV} bundle exec rake sidekiq:start"
  w.restart = "cd #{RAILS_ROOT} && RAILS_ENV=#{RAILS_ENV} bundle exec rake sidekiq:restart"
  w.stop = "cd #{RAILS_ROOT} && RAILS_ENV=#{RAILS_ENV} bundle exec rake sidekiq:stop"

  w.keepalive
end
